#!/usr/bin/env python3

import rclpy
from rclpy.node import Node

from bumperbot_msgs.srv import AddTwoInts


class SimpleServiceServer(Node):
    def __init__(self):
        super().__init__("simple_service_server_node")

        self.services_ = self.create_service(AddTwoInts, "add_two_ints",
            self.service_callback)
        self.get_logger().info("Service add_two_ints Ready")

    def service_callback(self, request, response):
        self.get_logger().info(f"Request Received a: {request.a}, b: {request.b}")  

        response.sum = request.a + request.b  
        self.get_logger().info(f"Returning sum: {response.sum}")
        return response
    

def main(args=None):
    rclpy.init(args=args)
    server_node = SimpleServiceServer()

    try:
        rclpy.spin(server_node)
    except KeyboardInterrupt:
        print("Terminating Node...")
    finally:
        server_node.destroy_node()
        rclpy.shutdown()

if __name__ == "__main__":
    main()